package net.vanchu.mortgagecalculator.mortgage.data.repaymentSummary;

import com.google.gson.Gson;

import net.vanchu.mortgagecalculator.common.config.LoanWay;

import java.io.Serializable;

/**
 * Created by Granton on 2016/12/14.
 */
public class RepaySummary implements Serializable {

    private LoanWay loanWay;

    private int numberOfMonths;

    public RepaySummary(LoanWay loanWay, int numberOfMonths) {
        this.loanWay = loanWay;
        this.numberOfMonths = numberOfMonths;
    }

    public LoanWay getLoanWay() {
        return loanWay;
    }

    public int getNumberOfMonths() {
        return numberOfMonths;
    }

    public String express() {
        Gson gson = new Gson();
        return gson.toJson(this);
    }

    public static class Single extends RepaySummary {

        private double principal;

        private TotalBalancedPart.Single totalBalancedPart;

        private PrincipalBalancedPart.Single principalBalancedPart;

        public Single(LoanWay loanWay, int numberOfMonths, double principal,
                      TotalBalancedPart.Single totalBalancedPart,
                      PrincipalBalancedPart.Single principalBalancedPart) {
            super(loanWay, numberOfMonths);
            this.principal = principal;
            this.totalBalancedPart = totalBalancedPart;
            this.principalBalancedPart = principalBalancedPart;
        }

        public double getPrincipal() {
            return principal;
        }

        public TotalBalancedPart.Single getTotalBalancedPart() {
            return totalBalancedPart;
        }

        public PrincipalBalancedPart.Single getPrincipalBalancedPart() {
            return principalBalancedPart;
        }
    }

    public static class Mix extends RepaySummary {

        private double principal;

        private TotalBalancedPart.Mix totalBalancedMix;

        private PrincipalBalancedPart.Mix principalBalancedMix;

        public Mix(LoanWay loanWay, int numberOfMonths, double principal,
                   TotalBalancedPart.Mix totalBalancedMix,
                   PrincipalBalancedPart.Mix principalBalancedMix) {
            super(loanWay, numberOfMonths);
            this.principal = principal;
            this.totalBalancedMix = totalBalancedMix;
            this.principalBalancedMix = principalBalancedMix;
        }

        public double getPrincipal() {
            return principal;
        }

        public TotalBalancedPart.Mix getTotalBalancedMix() {
            return totalBalancedMix;
        }

        public PrincipalBalancedPart.Mix getPrincipalBalancedMix() {
            return principalBalancedMix;
        }
    }
}